'''
@author: Thomas Moreau & Nicolas Berrez
'''

#!/usr/bin/env python2
#-*- coding: utf-8 -*-

import unittest
from game.Matrice import Matrice
from game.SnakeWord import SnakeWord
from game.Dico import Dico
from game.User import User

class MatriceTest(unittest.TestCase):
    def testMotValide(self):
        sw = SnakeWord(5, 4, "moi", 2, 42, Dico("../static/resources/dicofr.txt"), "super", False)
        sw.addPlayeur(User("pseudo", "mail", "userId", "numero"))
        sw.matrix.setMot("test")
        sw.wordEntered.add("test")
        self.assertTrue(sw.addWord(3, 3, "s", "tests"))

    def testErreur404(self):
        sw = SnakeWord(5, 4, "moi", 2, 42, Dico("../static/resources/dicofr.txt"), "super", False)
        sw.addPlayeur(User("pseudo", "mail", "userId", "numero"))
        sw.matrix.setMot("test")
        sw.wordEntered.add("test")
        self.assertTrue(sw.addWord(3, 3, "s", "canardenplastique") == "Ce mot n'est pas dans le dictionaire")
        
    def testErreur42(self):
        sw = SnakeWord(5, 4, "moi", 2, 42, Dico("../static/resources/dicofr.txt"), "super", False)
        sw.addPlayeur(User("pseudo", "mail", "userId", "numero"))
        sw.matrix.setMot("test")
        sw.wordEntered.add("test")
        self.assertTrue(sw.addWord(2, 3, "s", "tests") == "Cette case n'est pas vide")
    
    def testErreur51(self):
        sw = SnakeWord(5, 4, "moi", 2, 42, Dico("../static/resources/dicofr.txt"), "super", False)
        sw.addPlayeur(User("pseudo", "mail", "userId", "numero"))
        sw.matrix.setMot("test")
        sw.wordEntered.add("test")
        self.assertTrue(sw.addWord(3, 3, "s", "canard") == "Ce mot ne correspond pas a la grille")
        
    def testErreur66(self):
        sw = SnakeWord(5, 4, "moi", 2, 42, Dico("../static/resources/dicofr.txt"), "super", False)
        sw.addPlayeur(User("pseudo", "mail", "userId", "numero"))
        sw.matrix.setMot("test")
        sw.wordEntered.add("test")
        self.assertTrue(sw.addWord(1, 1, "t", "test") == "Ce mot a deja etait joue")
        
if __name__ == '__main__':
    unittest.main()